package com.endpoint.author.exception;

import com.endpoint.common.exception.BusinessException;
import com.endpoint.common.utils.ResultBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Project: endpoint
 * @Name: EndpointExceptionAdvice
 * @Author: Jack_Li
 * @Date: 2024/7/3 19:43
 */

@Slf4j
@RestControllerAdvice
public class EndpointExceptionAdvice {

    //处理业务异常
    @ExceptionHandler(BusinessException.class)
    public ResultBean handlerBusinessException(BusinessException e){
        log.error(e.getMessage(),e);
        return ResultBean.fail(e.getResStatus());
    }

    //处理系统异常
    @ExceptionHandler(Exception.class)
    public ResultBean handlerException(Exception e){
        log.error(e.getMessage(),e);
        return ResultBean.error();
    }
}
